(function (_super) {
    var io = ppt.io;

    function BeforeGame() {
        BeforeGame.super(this);

        this.BG = null;
        this.ani = null;
        this.aniLabel = null;

        this.init();
    }
    Laya.class(BeforeGame, "Game.BeforeGame", _super);
    var _proto = BeforeGame.prototype;
    _proto.destroy = function () {
        _super.prototype.destroy.call(this, true);

        io.unregister("game::begin", this.update);

        this.BG = null;
        this.ani = null;
    }

    _proto.init = function () {
        io.register("game::begin", this, this.update);

        this.mouseEnabled = true;
        this.alpha = 0;
        this.size(GAME_CONFIG.WIDTH, Laya.stage.height);
        this.create();
    }
    _proto.create = function () {
        var BG = new Laya.Image("res/public/mask.png");
            BG.alpha = 0.4;
            BG.left = 0;
            BG.right = 0;
            BG.top = 0;
            BG.bottom = 0;

        var ani = utils.createSkeleton("res/game/ui/counter");
            ani.pos(GAME_CONFIG.WIDTH / 2, Laya.stage.height / 2);

        this.BG = BG;
        this.ani = ani;
        this.addChildren(BG, ani);
    }
    _proto.update = function (data) {
        this.alpha = 1;

        if(data.time == 0){
            this.aniLabel = "go";
            for(var i in this._roles){
                this._roles[i].visible = true;
            }
            
            this.ani.once(Laya.Event.STOPPED, this, function () {
                this.removeSelf();
                this.visible = false;
            });
        }else{
            this.aniLabel = data.time + "";
        }
        
        this.ani.play(this.aniLabel, false);
    }
    
    _proto.resize = function (height) {
        this.height = height;
        this.ani.y = height / 2;
    }
})(Laya.Sprite);